<?php

namespace App\Http\Models\Admin;

use App\User;
use Spatie\Permission\Models\Role;

class Role_ extends Role
{

    protected $fillable = [
        'name','guard_name'
    ];
    public function folder()
    {
        //关联的模型类名, 关系字段 
        return $this->belongsToMany('App\Http\Models\Admin\Folder', 'folder_has_roles', 'roles_id', 'folder_id');
    }


    public function roles_belongsToMany() 
    {
        //关联的模型类名, 关系字段 
        return $this->belongsToMany('App\Http\Models\Admin\Permission_','role_has_permissions','permission_id','role_id');
    }

        
    public function classifyHasMany()
    {
        return $this->hasMany(get_class($this), 'parent_id');
    }

    public function hasManyDetails()
    {
        //关联的模型类名, 关系字段
        return $this->belongsToMany('App\Http\Models\Admin\Permission_','role_has_permissions','role_id','permission_id');
    }


    public function hasDetails()
        {
            //关联的模型类名, 关系字段
            return $this->belongsToMany('App\Http\Models\Admin\RolePermissions','permission_id');
        }

}
